package com.koron.order.experiment.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.experiment.bean.po.ExperimentEquipmentSignPo;
import com.koron.order.experiment.service.ExperimentEquipmentSignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (ExperimentEquipmentSign)表控制层
 *
 * @author zhouj
 * @since 2021-11-08 17:51:50
 */
@Api(tags = "(试验工单-设备试验员签名信息)")
@RestController
@RequestMapping("/experimentEquipmentSign/")
public class ExperimentEquipmentSignController {

    @Autowired
    private ExperimentEquipmentSignService experimentEquipmentSignService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改")
    @PostMapping("insertOrUpdate")
    public Response<String> insertOrUpdate(@RequestBody ExperimentEquipmentSignPo experimentEquipmentSign) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "insertOrUpdate", String.class, experimentEquipmentSign));
    }

    @ApiOperation(value = "新增或修改-批量")
    @PostMapping("insertOrUpdateBatch")
    public Response<Integer> insertOrUpdateBatch(@RequestBody List<ExperimentEquipmentSignPo> experimentEquipmentSignList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "insertOrUpdateBatch", Integer.class, experimentEquipmentSignList));
    }

    @ApiOperation(value = "新增")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody ExperimentEquipmentSignPo experimentEquipmentSign) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "insert", Integer.class, experimentEquipmentSign));
    }

    @ApiOperation(value = "批量新增")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<ExperimentEquipmentSignPo> experimentEquipmentSignList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "insertBatch", Integer.class, experimentEquipmentSignList));
    }

    @ApiOperation(value = "根据id更新")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody ExperimentEquipmentSignPo experimentEquipmentSign) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "update", Integer.class, experimentEquipmentSign));
    }

    @ApiOperation(value = "根据id删除")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("queryById")
    public Response<ExperimentEquipmentSignPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "queryById", ExperimentEquipmentSignPo.class, id));
    }

    @ApiOperation(value = "不分页查询列表")
    @GetMapping("queryList")
    public Response<List> queryList(ExperimentEquipmentSignPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(ExperimentEquipmentSignPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), experimentEquipmentSignService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
